<?php
/**
 * 订阅
 */
class FeedAction {
	private $baseUrl = '';
	
	public function __construct() {
		$this->baseUrl = y_getHost();
	}
	
	// 默认订阅技术
	public function index() {
		import('ORG.Util.Rss');
		
		// 拿到文章
		$dataList = M('Article')->field('id,title,author,description,posttime')->order('id desc')->limit(100)->select();
		
		$rss = new Rss(
			'文章订阅', 
			$this->baseUrl . '/Feed', 
			$this->baseUrl . '/Article', 
			'最新文章');
		
		for($i = 0; $i < count($dataList); $i++) {
			$rss->addItem(
				$dataList[$i]['title'], 
				$this->baseUrl . '/Detail/index/id/' . $dataList[$i]['id'], 
				$dataList[$i]['author'], 
				$dataList[$i]['posttime'], 
				$dataList[$i]['description'], 
				$dataList[$i]['description'] . '<br />详情......');
		}
		
		$rss->show();
	}
}